import createHeading from './heading.js'
import './main.css'
// import icon from './icon.png'

const heading = createHeading()

document.body.append(heading)



// const img = new Image()
// img.src = icon

// document.body.append(img)

// import footerHtml from './footer.html'
// document.write(footerHtml)

// import about from './about.md'
// document.write(about)



const ul = document.createElement('ul')
document.body.append(ul)
// 跨域请求 虽然github 支持CORS 但是不是每个服务端都应该支持
fetch('/api/users').then(res => res.json()).then(data=>{
  data.forEach(item=>{
    const li = document.createElement('li')
    li.innerHTML = item.login
    ul.append(li)
  })
})


// =====HMR热替换 与业务代码无关======
// let lastHeading = heading
// module.hot.accept('./heading',() => {
//   const val = lastHeading.innerHTML
//   document.body.removeChild(lastHeading)
//   const newHeading = createHeading()
//   newHeading.innerHTML = val
//   document.body.appendChild(newHeading)
//   lastHeading = newHeading  // 替换原先的
// })


// console.log(API_BASE_URL)